<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
    {{time | date | slice | currency}}
</div>
</body>
<script>
    // 串联：过滤器可以使用多个。依次自左向右进行过滤的
	new Vue({
		el:"#root",
        data:{
		    time:Date.now()
        },
		filters:{
			currency(v,type="￥",len=2){
				return type+(v/1).toFixed(len);
			},
            slice(v){
				return v.slice(0,4)
            },
			date(v){
				const time = new Date(v);
				return time.getFullYear()+"-"+
					(time.getMonth()+1).toString().padStart(2,0)+"-"+
					time.getDate().toString().padStart(2,0)+" "+
					time.getHours().toString().padStart(2,0)+":"+
					time.getMinutes().toString().padStart(2,0)+":"+
					time.getSeconds().toString().padStart(2,0);
			}
		}
	})
</script>
</html>